<?php require ROOT_PATH . 'views/layouts/header.php'; ?>

<div class="container main-content">
    <h2>动态详情</h2>

    <div class="main-tweet">
        <?php
            $tweet = $mainTweet; // 将主推文赋值给 $tweet 以便组件使用
            require ROOT_PATH . 'views/_tweet.php';
        ?>
    </div>

    <div class="reply-form-container">
        <h4>回复这条动态</h4>
        <form action="/tweet/create" method="post">
            <input type="hidden" name="parent_id" value="<?php echo $mainTweet['id']; ?>">
            <textarea name="content" rows="2" placeholder="输入你的回复..." required></textarea>
            <button type="submit">回复</button>
        </form>
    </div>

    <div class="replies-section">
        <h3>所有回复</h3>
        <?php
        if (empty($replies)) {
            echo "<p>还没有人回复。</p>";
        } else {
            foreach ($replies as $reply) {
                $tweet = $reply; // 将回复赋值给 $tweet 以便组件使用
                require ROOT_PATH . 'views/_tweet.php';
            }
        }
        ?>
    </div>
</div>

<?php require ROOT_PATH . 'views/layouts/footer.php'; ?>
